<?php
/**
* @package RAM_AreaSectorSearch
* @version 1.5.0 Stable, September 2009
*/

class mod_hot_candidatesHelper 
{
	function getLatestjobs($no_to_display)    
	{
		global $msg;
	
		$jobs = array();
	
		//get the database configuration settings
		$conf =& JFactory::getConfig();
		$dbhost = $conf->getValue('config.host');
		$dbuser = $conf->getValue('config.user');
		$dbpassword = $conf->getValue('config.password');
		$dbname = $conf->getValue('config.db');
		$dbprefix = $conf->getValue('config.dbprefix');
	
		// connect to the database
		mysql_connect($dbhost,$dbuser,$dbpassword) or die("mysql_connect fail");
		mysql_select_db($dbname) or die("mysql_select_db fail");
	
		$query = "SELECT j.id, j.jobtitle, c.clientname, a.Country, a.County, s.desc FROM ".$dbprefix."ram_jobs as j ";
		$query .= "LEFT JOIN ".$dbprefix."ram_clients as c ON j.company = c.id ";
		$query .= "LEFT JOIN ".$dbprefix."ram_areas as a ON j.area = a.id ";
		$query .= "LEFT JOIN ".$dbprefix."ram_ratebands as s ON j.salaryrange = s.id ";
		$query .= "WHERE j.jobfilled='n' ";
		$query .= "ORDER BY j.id desc ";
		$query .= "LIMIT 0, $no_to_display";
		
		//echo "<p>SQL: $query</p>\n";
		$sth=mysql_query($query);
		$num_rows = mysql_num_rows($sth);
		// records found?	
		if ($num_rows>0) {
			// yes
			while ($row=mysql_fetch_array($sth, MYSQL_ASSOC)) {
				$jobs[] = $row; // add the job details to the array
			}
	
		} else { // no, return error message
			$msg = JText::_('RAM_LJM_NOJOBS');
		} // eof check for records found

        return $jobs; // return any jobs found

	} // end function getLatestjobs
} 
?>
